#include<stdio.h>
int n;

int find(int b[]){
int l=0,r=n-1,i;
while(l<r){
    int mid=(l+r)>>1;
    int count=0;
    for(i=0;i<n;i++){
        if(b[i]>=0&&b[i]<=mid)
            count++;
    }
    if(count>mid-l+1)
        r = mid;
    else
        l=mid+1;
    
}
return r;
}
int main(){
scanf("%d",&n);
int a[n],i;
for(i=0;i<n;i++)
    scanf("%d",&a[i]);
int key=find(a),count1=0;
for(i=0;i<n;i++){
    if(a[i]==key)
    count1++;
    }
if(count1>n/2)
    printf("%d",key);
else
    printf("%d",-1);
}